impl Solution {
    pub fn can_be_valid(s: String, locked: String) -> bool {
        if s.len() % 2 != 0 {
            return false;
        }
        let mut count = 0;
        let mut count2 = 0;
        s.bytes()
            .zip(locked.bytes())
            .enumerate()
            .all(|(ind, (b, l))| {
                if l == b'1' && b == b')' {
                    count += 1;
                    if ind + 1 - count < count {
                        return false;
                    }
                }

                true
            })
            && s.bytes()
                .zip(locked.bytes())
                .enumerate()
                .rev()
                .all(|(ind, (b, l))| {
                    if l == b'1' && b == b'(' {
                        count2 += 1;
                        if s.len() - ind - count2 < count2 {
                            return false;
                        }
                    }
                    true
                })
    }
}
